%Calculate model quantities as a function of time

V0=kappa*q;

[m,ind]=min(abs(sol.x-V0));

%Solve time ODE to calculate model quantities as a function of time
solVTime=ode15s(@OdeTime,[0 T],[V0 F0 dF0 beta0],options,sol.x, sol.y, vA, gamma,phi,q,Lambda,r,delta, VB,vC,vD,solQuant.x,betaB );


%Save results in vector form
vbetat=zeros(length(solVTime.x),1);
vtaut=zeros(length(solVTime.x),1);
vAt=zeros(length(solVTime.x),1);

for t=1:length(solVTime.x)
    
    [m,ind]=min(abs(solVTime.y(1,t)-sol.x));
    vFt(t)=solVTime.y(2,t);
    
    vAt(t)=vA(ind);
 
    vWt(t)=vA(ind)*phi;
    vVt(t)=vV(ind);
    vCt(t)=vC(ind);
    
    
    [m,ind2]=min(abs(solVTime.y(1,t)-solQuant.x));
    [m,indQuant]=min(abs(smooth(solVTime.y(1,t))-quantGrid));
    vbetat(t)=vbeta(ind2);
    vbetat(t)=vbetaFine(indQuant);
    vDt(t)=vD(ind2);
    vtaut(t)=vtau(ind2);
    
    
end


